const Mock = require('mockjs') // 导入Mock
const fs = require('fs'); // 导入fs文件模块

const Random = Mock.Random;
const data = Mock.mock({
    'admin|11': [
        {
            'id|+1': 1,
            username: '@cname',
            'tel|13000000000-19999999999': 1,
            'password|100-999': 1
        }
    ],
    'dorm|3': [
        {
            'id|+1': 1,
            u_id: 1,
            "img": Random.image('60x60', '#4A7BF7', '66')
        }
    ],
    'test|20': [{
        'id|+1': 1,
        'code|0-666': 1,

        "state|1": [
            "未提交",
            "已升级二线",
            "已升级三线",
            "已升级重大故障",
            "已初步评估",
            "已诊断分析",
            "已关闭"
        ],
        data: '@date("yyyy-MM-dd")',
        "link|1": [
            "自我解决",
            "转派同级其他人员",
            "升级为二线",
            "升级为三线",
            "分派修复小组",
            "升级为重大故障",
        ],
        user: '@cname',
        'pri|1-5': "★",
        "type|1": [
            "用户编辑故障",
            "系统编辑故障",
        ],
        "impact|1": [
            "低",
            "中",
            "高",
            "特",
        ],
        abstract: '@string(5)',
        information: '@string(10)',
        annex: '',
        "eventtype|1": [
            '故障',
            '服务清求',
            '服务咨询',
            '安全类事件',
        ],
        "eventclass|1": [
            '网络系统',
            '服务器系统',
            '门户网站',
            '应用系统',
            '桌面系统',
            '机房管理',
        ],
        "eventsource|1": [
            '电话',
            'Web',
            '监控系统',
            '电子邮件',
        ],
        "sourceinstitution|1": [
            '指挥中心',
            '信息中心',
        ],
        'phone|13000000000-19999999999': 1,
        adress: '四川省@string(5)',
        handletime: '1',
        handlefangshi: '2',
        handlebumen: '服务台'
    }],
    'test2': [{
        id: 1,
        content: '数据1',
        data: '2023-12-23',
        name: '王x',
        url: ''
    },
    {
        id: 2,
        content: '数据1',
        name: '李x',
        data: '2023-01-23',
    },
    {
        id: 3,
        content: '数据1',
        name: '陈x',
        data: '2023-2-23',
    },],

    'Linux|14': [{
        'id|+1': 1,
        title: '@ctitle(6,11)',
        content: '@cparagraph(3,5)',
        creater: '@cname',
        time: '@datetime'
    }],
    'Window|14': [{
        'id|+1': 1,
        title: '@ctitle(6,11)',
        content: '@cparagraph(3,5)',
        creater: '@cname',
        time: '@datetime'
    }],
    'Server1|14': [{
        'id|+1': 1,
        title: '@ctitle(6,11)',
        content: '@cparagraph(3,5)',
        creater: '@cname',
        time: '@datetime'
    }],
    'Server2|14': [{
        'id|+1': 1,
        title: '@ctitle(6,11)',
        content: '@cparagraph(3,5)',
        creater: '@cname',
        time: '@datetime'
    }],
    'Firewall1|14': [{
        'id|+1': 1,
        title: '@ctitle(6,11)',
        content: '@cparagraph(3,5)',
        creater: '@cname',
        time: '@datetime'
    }],
    'Firewall2|14': [{
        'id|+1': 1,
        title: '@ctitle(6,11)',
        content: '@cparagraph(3,5)',
        creater: '@cname',
        time: '@datetime'
    }],
    'Zdpz-1|13':[{
        'id|+1': 1,
        name:'@cname',
        description:'@cparagraph(1)',
        type:'@Boolean'
    }],
    'Zdpz-2|13':[{
        'id|+1': 1,
        name:'@cname',
        description:'@cparagraph(1)',
        type:'@Boolean'
    }],
    'Zdpz-3|13':[{
        'id|+1': 1,
        name: '@cname',
        description: '@cparagraph(1)',
        type: '@Boolean'
    }],

    'WuJiETianJia|10': [{
        'id|+1': 1,
        "bianma|+1": 1,
        "fangan|1": ["默认通电状态"],
        "fenlei|1": ["软件类", "硬件类", "文档类"],
        "biaodan|1": ["全部", "服务器", "储存", "网络设备", "机房环境", "桌面PC", "外设"],
        "miaoshu|1": ["服务器报警", "储存报警", "网络设备报警", "机房环境报警", "桌面PC报警", "外设报警"]
    }],
    'wuJiThree|30': [{
        "id|+1": 1,
        'shebeiID|+1': 1,
        'zichanmingcheng|1': ['计财用友数据库', 'CRM系统', 'CRB系统'],
        'wangluoshuxing|1': ['涉密', '公用'],
        'suoshujifang|1': ['外网机房', '内网机房'],
        'IPdizhi|1': ['192.168.23.1', '193.168.1.2'],
        'zerenren|1': ['李小龙', '张无忌', '王菲', '杨过', '李靖'],
        'shiyongzhuangtai|1': ['正常', '故障'],
    }],
    'wuJiFour|25': [{
        'id|+1': 1,
        'mingcheng|1': ["操作系统", "CRM系统", "网安系统", "其它系统"],
        "shuliang|1": ["22", "33", "56"],
        "bitianxiang|1": "必填项",
    }],
     //部门管理
     'section|10':[{
        'id|+1':1,
        name: '@cword(3)',
        time: '@datetime',
        ren: '@cname',
        status: Random.integer(0, 1)
     }],
     'section1|10':[{
        'id|+1':1,
        name: '@cword(3)',
        time: '@datetime',
        ren: '@cname',
        status: Random.integer(0, 1)
     }],
     'section2|10':[{
        'id|+1':1,
        name: '@cword(3)',
        time: '@datetime',
        ren: '@cname',
        status: Random.integer(0, 1)
     }],
     'section3|10':[{
        'id|+1':1,
        name: '@cword(3)',
        time: '@datetime',
        ren: '@cname',
        status: Random.integer(0, 1)
     }],
     //权限名称
    'limits|10':[{
        'id|+1':1,
        name: () => Random.pick(['权限A', '权限B', '权限C']),
        createquan:'@ctitle(5)',
        createtime:'@datetime',
        createUser:'@cname',
        isEnabled:Random.integer(0, 1)
    }],
    //用户管理
    'user|10':[{
        'id|+1':1,
        name:'@cword(3)',
        bumen: "@pick(@section).name",
        quanxian: "@pick(@limits).name",
        time:'@datetime',
        ren:'@cname'
    }],
    'user1|10':[{
        'id|+1':1,
        name:'@cword(3)',
        bumen: "@pick(@section).name",
        quanxian: "@pick(@limits).name",
        time:'@datetime',
        ren:'@cname'
    }],
    'user2|10':[{
        'id|+1':1,
        name:'@cword(3)',
        bumen: "@pick(@section).name",
        quanxian: "@pick(@limits).name",
        time:'@datetime',
        ren:'@cname'
    }],
    'user3|10':[{
        'id|+1':1,
        name:'@cword(3)',
        bumen: "@pick(@section).name",
        quanxian: "@pick(@limits).name",
        time:'@datetime',
        ren:'@cname'
    }],
    //组织管理
    'list|10': [{
        'id|+1': 1,
        name: '@ctitle(3,5)',
        createTime: '@datetime',
        createUser: '@cname',
        isEnabled: Random.integer(0, 1)
    }],
    'Lcpz|12':[{
        'id|+1': 1,
        name: '@cname',
        describe: '@cparagraph(1)',
        type:'@Boolean',
        time:'@date',
        "number|1-100": 100

    }],
    'Gdmb|20':[{
        'id|+1': 1,
        name: '@cname',
        describe: '@cparagraph(1)',
        type:'@Boolean',
        

    }],

})
Mock.mock('/taianjia/', 'post', (option) => {
    let data = JSON.parse(option.body)
    if (data.name && data.miaoshu) {
        return {
            code: 200,
            msg: '添加成功',
            data: data
        }
    } else {
        return {
            code: 200,
            msg: '添加失败',
        }
    }
})

//写文件
fs.writeFile('./login.json', JSON.stringify(data), function () {  // 写入数据到json文件  
    console.log('数据写入成功！')
})